package com.hj.aimin.drug.service;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
import com.hj.aimin.drug.entity.Drug;
import com.hj.aimin.drug.mapper.DrugMapper;
import com.hj.aimin.drug.service.DrugService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 药品表，用于存储具体药品的信息和库存状态 服务实现类
 * </p>
 *
 * @author root
 * @since 2025/10/28
 */
@Service
public class DrugServiceImpl extends ServiceImpl<DrugMapper, Drug> implements DrugService {

    @Override
    @Cacheable(value = "drugCache",key = "#categoryId")
    public List<Drug> findByCategoryId(Integer categoryId) {
        return list(new LambdaQueryWrapper<Drug>().eq(Drug::getCategoryId,categoryId));
    }

}
